package org.example.project.controller;

import lombok.RequiredArgsConstructor;
import org.example.project.common.convention.result.Result;
import org.example.project.common.convention.result.Results;
import org.example.project.service.UrlTitleService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 获取目标 URL 标题控制器
 *
 * @author weibin
 * @since 2025/10/13 19:45
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/project")
public class UrlTitleController {

    private final UrlTitleService urlTitleService;

    @PostMapping("/urlTitle")
    public Result<String> getUrlTitle(@RequestParam("url") String url) {
        return Results.success(urlTitleService.getUrlTitle(url));
    }

}
